/*
 * Killocan 2013
 * http://killocan.blogspot.com
*/

#include "gutsmanstage.h"
#include "globals.h"
#include "stage.h"
#include "soundpack.h"
#include "spritefiles.h"
#include "sfx.h"

GutsManStage::GutsManStage() : bPlayingPlatformSound(false)
{
  STAGE_PATH = "./gutsman_stage";
}

GutsManStage::~GutsManStage()
{
  Sounds::mm_sounds->stopSample(PLATFORM_MOVE);
}

void GutsManStage::setupStage()
{
  stage->setOffset(mm_spritefiles::BIGEYE_SPRITES,         0); // set which sprite color to use.
  stage->setOffset(mm_spritefiles::FLEA_SPRITES,           0); // set which sprite color to use.

  stage->hasMovingPlatform = true;
  stage->platformTiles.push_back(21); // normal move
  stage->platformTiles.push_back(20); // bounce back
  stage->platformTiles.push_back(22); // hole
}

void GutsManStage::doStageSpecifics()
{
  if (stage->m_player->x > 840)
  {
    if (bPlayingPlatformSound == false && stage->m_player->x < 2350)
    {
      Sounds::mm_sounds->play(PLATFORM_MOVE, true);
      bPlayingPlatformSound = true;
    }
    else
    {
      if (stage->m_player->x > 2350)
      {
        Sounds::mm_sounds->stopSample(PLATFORM_MOVE);
        bPlayingPlatformSound = false;        
      }
    }
  }
  else
  {
    if (bPlayingPlatformSound == true)
    {
      Sounds::mm_sounds->stopSample(PLATFORM_MOVE);
      bPlayingPlatformSound = false;
    }
  }
}

SceneSoundManager * GutsManStage::CreateSoundManager()
{
  return new SceneSoundManager(mm_soundpack::sounds[mm_soundpack::GUTSMAN_BG_MUSIC]);
}
